package com.example.AndroidSms;

import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class AndroidSms extends Activity {

	/** Called when the activity is first created. */

	@Override
	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		Button button = (Button) this.findViewById(R.id.send);
		button.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				EditText mobileText = (EditText) findViewById(R.id.mobile);
				String mobile = mobileText.getText().toString();
				EditText messageText = (EditText) findViewById(R.id.message);
				String message = messageText.getText().toString();

				if (message != null) {

					SmsManager sms = SmsManager.getDefault();
					List<String> texts = sms.divideMessage(message);

					for (String text : texts) {
						sms.sendTextMessage(mobile, null, text, null, null);

					}
				}
			}
		});
	}
}